<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>sock: sock::net::Socket Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">sock
   &#160;<span id="projectnumber">v0.11</span>
   </div>
   <div id="projectbrief">C++ Network Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacesock.html">sock</a></li><li class="navelem"><a class="el" href="namespacesock_1_1net.html">net</a></li><li class="navelem"><a class="el" href="classsock_1_1net_1_1_socket.html">Socket</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classsock_1_1net_1_1_socket-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">sock::net::Socket Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>套接字  
 <a href="classsock_1_1net_1_1_socket.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="socket_8h_source.html">socket.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for sock::net::Socket:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classsock_1_1net_1_1_socket.png" usemap="#sock::net::Socket_map" alt=""/>
  <map id="sock::net::Socket_map" name="sock::net::Socket_map">
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ae42299933b7d6448b99ab840f04471b8"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#ae42299933b7d6448b99ab840f04471b8">Socket</a> (sock_t sock)</td></tr>
<tr class="separator:ae42299933b7d6448b99ab840f04471b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac9963a648d5421365c29dfc1af2acecb"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#ac9963a648d5421365c29dfc1af2acecb">Socket</a> (int family, int type, int protocol)</td></tr>
<tr class="separator:ac9963a648d5421365c29dfc1af2acecb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a763aae809efa471def8e7918281c3a1c"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a763aae809efa471def8e7918281c3a1c">~Socket</a> (void)</td></tr>
<tr class="separator:a763aae809efa471def8e7918281c3a1c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abf71d50699036a8a69cb362a9ac7ad02"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#abf71d50699036a8a69cb362a9ac7ad02">close</a> (void)</td></tr>
<tr class="separator:abf71d50699036a8a69cb362a9ac7ad02"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a31726f1fff129300731ef86d90b7eec4"><td class="memItemLeft" align="right" valign="top">sock_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a31726f1fff129300731ef86d90b7eec4">getSock</a> (void) const </td></tr>
<tr class="memdesc:a31726f1fff129300731ef86d90b7eec4"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取本地套接字  <a href="#a31726f1fff129300731ef86d90b7eec4">More...</a><br /></td></tr>
<tr class="separator:a31726f1fff129300731ef86d90b7eec4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a25675e062ae83762dd1e25ef745f6ba1"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a25675e062ae83762dd1e25ef745f6ba1">receive</a> (char *buff, size_t length, int flags=0)</td></tr>
<tr class="memdesc:a25675e062ae83762dd1e25ef745f6ba1"><td class="mdescLeft">&#160;</td><td class="mdescRight">接收数据  <a href="#a25675e062ae83762dd1e25ef745f6ba1">More...</a><br /></td></tr>
<tr class="separator:a25675e062ae83762dd1e25ef745f6ba1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af2218f65624a640161009ddd0bfa509e"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#af2218f65624a640161009ddd0bfa509e">send</a> (const char *buff, size_t length, int flags=0)</td></tr>
<tr class="memdesc:af2218f65624a640161009ddd0bfa509e"><td class="mdescLeft">&#160;</td><td class="mdescRight">发送数据  <a href="#af2218f65624a640161009ddd0bfa509e">More...</a><br /></td></tr>
<tr class="separator:af2218f65624a640161009ddd0bfa509e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae714f7ccae9a27faf665ac3570022c3e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#ae714f7ccae9a27faf665ac3570022c3e">getpeername</a> (struct sockaddr *addr, socklen_t *addrlen)</td></tr>
<tr class="memdesc:ae714f7ccae9a27faf665ac3570022c3e"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取套接字远程地址  <a href="#ae714f7ccae9a27faf665ac3570022c3e">More...</a><br /></td></tr>
<tr class="separator:ae714f7ccae9a27faf665ac3570022c3e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a91f3a52d5e6ede3892cc8cbd8ac34a13"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a91f3a52d5e6ede3892cc8cbd8ac34a13">getsockname</a> (struct sockaddr *addr, socklen_t *addrlen)</td></tr>
<tr class="memdesc:a91f3a52d5e6ede3892cc8cbd8ac34a13"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取套接字本地地址  <a href="#a91f3a52d5e6ede3892cc8cbd8ac34a13">More...</a><br /></td></tr>
<tr class="separator:a91f3a52d5e6ede3892cc8cbd8ac34a13"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:ad378344115303d72510ca9df7124629a"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#ad378344115303d72510ca9df7124629a">setOption</a> (sock_t sock, int level, int optname, const void *optval, socklen_t optlen)</td></tr>
<tr class="memdesc:ad378344115303d72510ca9df7124629a"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置套接字选项  <a href="#ad378344115303d72510ca9df7124629a">More...</a><br /></td></tr>
<tr class="separator:ad378344115303d72510ca9df7124629a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afbaabe6b8436c32418cd14a6253a1f70"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#afbaabe6b8436c32418cd14a6253a1f70">getOption</a> (sock_t sock, int level, int optname, void *optval, socklen_t *optlen)</td></tr>
<tr class="memdesc:afbaabe6b8436c32418cd14a6253a1f70"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取套接字选项  <a href="#afbaabe6b8436c32418cd14a6253a1f70">More...</a><br /></td></tr>
<tr class="separator:afbaabe6b8436c32418cd14a6253a1f70"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac128e602223fe5a9416b3f1a67009282"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#ac128e602223fe5a9416b3f1a67009282">setNonblocking</a> (sock_t sock, bool on)</td></tr>
<tr class="memdesc:ac128e602223fe5a9416b3f1a67009282"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置IO阻塞状态  <a href="#ac128e602223fe5a9416b3f1a67009282">More...</a><br /></td></tr>
<tr class="separator:ac128e602223fe5a9416b3f1a67009282"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2476dc993b75de2de00955468508fc8c"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a2476dc993b75de2de00955468508fc8c">setLinger</a> (sock_t sock, bool on)</td></tr>
<tr class="memdesc:a2476dc993b75de2de00955468508fc8c"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置linger模式  <a href="#a2476dc993b75de2de00955468508fc8c">More...</a><br /></td></tr>
<tr class="separator:a2476dc993b75de2de00955468508fc8c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a94e161e16e429d119a01aaf6c8a5f13a"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a94e161e16e429d119a01aaf6c8a5f13a">setReuseAddr</a> (sock_t sock, bool on)</td></tr>
<tr class="memdesc:a94e161e16e429d119a01aaf6c8a5f13a"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置重用地址  <a href="#a94e161e16e429d119a01aaf6c8a5f13a">More...</a><br /></td></tr>
<tr class="separator:a94e161e16e429d119a01aaf6c8a5f13a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99e8e002c913cef15af249853acd0d66"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a99e8e002c913cef15af249853acd0d66">close</a> (sock_t &amp;sock)</td></tr>
<tr class="memdesc:a99e8e002c913cef15af249853acd0d66"><td class="mdescLeft">&#160;</td><td class="mdescRight">关闭套接字  <a href="#a99e8e002c913cef15af249853acd0d66">More...</a><br /></td></tr>
<tr class="separator:a99e8e002c913cef15af249853acd0d66"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aad44251cdf6b0c9c32fd22f9e372dd7c"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#aad44251cdf6b0c9c32fd22f9e372dd7c">receive</a> (sock_t sock, char *buff, size_t length, int flags=0)</td></tr>
<tr class="memdesc:aad44251cdf6b0c9c32fd22f9e372dd7c"><td class="mdescLeft">&#160;</td><td class="mdescRight">接收数据  <a href="#aad44251cdf6b0c9c32fd22f9e372dd7c">More...</a><br /></td></tr>
<tr class="separator:aad44251cdf6b0c9c32fd22f9e372dd7c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1185de0328e0ff6a2f2f10c0a6591a61"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a1185de0328e0ff6a2f2f10c0a6591a61">send</a> (sock_t sock, const char *buff, size_t length, int flags=0)</td></tr>
<tr class="memdesc:a1185de0328e0ff6a2f2f10c0a6591a61"><td class="mdescLeft">&#160;</td><td class="mdescRight">发送数据  <a href="#a1185de0328e0ff6a2f2f10c0a6591a61">More...</a><br /></td></tr>
<tr class="separator:a1185de0328e0ff6a2f2f10c0a6591a61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d2d51ecf142baed689d2baf9c90da70"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#a2d2d51ecf142baed689d2baf9c90da70">getpeername</a> (sock_t sock, struct sockaddr *addr, socklen_t *addrlen)</td></tr>
<tr class="memdesc:a2d2d51ecf142baed689d2baf9c90da70"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取套接字远程地址  <a href="#a2d2d51ecf142baed689d2baf9c90da70">More...</a><br /></td></tr>
<tr class="separator:a2d2d51ecf142baed689d2baf9c90da70"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4de126b57c1ed0851192b6a7434a37d"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsock_1_1net_1_1_socket.html#ae4de126b57c1ed0851192b6a7434a37d">getsockname</a> (sock_t sock, struct sockaddr *addr, socklen_t *addrlen)</td></tr>
<tr class="memdesc:ae4de126b57c1ed0851192b6a7434a37d"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取套接字本地地址  <a href="#ae4de126b57c1ed0851192b6a7434a37d">More...</a><br /></td></tr>
<tr class="separator:ae4de126b57c1ed0851192b6a7434a37d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>套接字 </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ae42299933b7d6448b99ab840f04471b8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Socket::Socket </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="ac9963a648d5421365c29dfc1af2acecb"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Socket::Socket </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>family</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>protocol</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a763aae809efa471def8e7918281c3a1c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Socket::~Socket </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="abf71d50699036a8a69cb362a9ac7ad02"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Socket::close </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>关闭套接字 </p>

</div>
</div>
<a class="anchor" id="a99e8e002c913cef15af249853acd0d66"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Socket::close </td>
          <td>(</td>
          <td class="paramtype">sock_t &amp;&#160;</td>
          <td class="paramname"><em>sock</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>关闭套接字 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>本地套接字 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="afbaabe6b8436c32418cd14a6253a1f70"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::getOption </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>level</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>optname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>optval</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">socklen_t *&#160;</td>
          <td class="paramname"><em>optlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取套接字选项 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>本地套接字 </td></tr>
    <tr><td class="paramname">level</td><td>选项等级 </td></tr>
    <tr><td class="paramname">optname</td><td>选项名 </td></tr>
    <tr><td class="paramname">optval</td><td>选项值 </td></tr>
    <tr><td class="paramname">optlen</td><td>选项长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>bool </dd></dl>

</div>
</div>
<a class="anchor" id="ae714f7ccae9a27faf665ac3570022c3e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::getpeername </td>
          <td>(</td>
          <td class="paramtype">struct sockaddr *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">socklen_t *&#160;</td>
          <td class="paramname"><em>addrlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>获取套接字远程地址 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">addr</td><td>地址缓存 </td></tr>
    <tr><td class="paramname">addrlen</td><td>地址长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>失败返回false </dd></dl>

</div>
</div>
<a class="anchor" id="a2d2d51ecf142baed689d2baf9c90da70"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::getpeername </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct sockaddr *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">socklen_t *&#160;</td>
          <td class="paramname"><em>addrlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取套接字远程地址 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>套接字句柄 </td></tr>
    <tr><td class="paramname">addr</td><td>地址缓存 </td></tr>
    <tr><td class="paramname">addrlen</td><td>地址长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>失败返回false </dd></dl>

</div>
</div>
<a class="anchor" id="a31726f1fff129300731ef86d90b7eec4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">sock_t sock::net::Socket::getSock </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取本地套接字 </p>
<dl class="section return"><dt>Returns</dt><dd>sock_t </dd></dl>

</div>
</div>
<a class="anchor" id="a91f3a52d5e6ede3892cc8cbd8ac34a13"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::getsockname </td>
          <td>(</td>
          <td class="paramtype">struct sockaddr *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">socklen_t *&#160;</td>
          <td class="paramname"><em>addrlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>获取套接字本地地址 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">addr</td><td>地址缓存 </td></tr>
    <tr><td class="paramname">addrlen</td><td>地址长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>失败返回false </dd></dl>

</div>
</div>
<a class="anchor" id="ae4de126b57c1ed0851192b6a7434a37d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::getsockname </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct sockaddr *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">socklen_t *&#160;</td>
          <td class="paramname"><em>addrlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取套接字本地地址 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>套接字句柄 </td></tr>
    <tr><td class="paramname">addr</td><td>地址缓存 </td></tr>
    <tr><td class="paramname">addrlen</td><td>地址长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>失败返回false </dd></dl>

</div>
</div>
<a class="anchor" id="a25675e062ae83762dd1e25ef745f6ba1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Socket::receive </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>接收数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buff</td><td>数据缓存 </td></tr>
    <tr><td class="paramname">length</td><td>数据缓存长度 </td></tr>
    <tr><td class="paramname">flags</td><td>标志 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回接收的数据长度，如果套接字非阻塞且数据 已接收完返回SOCKET_ERROR_WOULDBLOCK，错误返回SOCKET_ERROR </dd></dl>

</div>
</div>
<a class="anchor" id="aad44251cdf6b0c9c32fd22f9e372dd7c"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Socket::receive </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>接收数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>本地套接字 </td></tr>
    <tr><td class="paramname">buff</td><td>数据缓存 </td></tr>
    <tr><td class="paramname">length</td><td>数据缓存长度 </td></tr>
    <tr><td class="paramname">flags</td><td>标志 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回接收的数据长度，如果套接字非阻塞且数据 已接收完返回SOCKET_ERROR_WOULDBLOCK，错误返回SOCKET_ERROR </dd></dl>

</div>
</div>
<a class="anchor" id="af2218f65624a640161009ddd0bfa509e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Socket::send </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>buff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>发送数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buff</td><td>数据缓存 </td></tr>
    <tr><td class="paramname">length</td><td>数据缓存长度 </td></tr>
    <tr><td class="paramname">flags</td><td>标志 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功发送接收的数据长度，如果套接字非阻塞且数据 发送缓存已满返回SOCKET_ERROR_WOULDBLOCK，错误返回SOCKET_ERROR </dd></dl>

</div>
</div>
<a class="anchor" id="a1185de0328e0ff6a2f2f10c0a6591a61"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Socket::send </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>buff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>发送数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>本地套接字 </td></tr>
    <tr><td class="paramname">buff</td><td>数据缓存 </td></tr>
    <tr><td class="paramname">length</td><td>数据缓存长度 </td></tr>
    <tr><td class="paramname">flags</td><td>标志 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功发送接收的数据长度，如果套接字非阻塞且数据 发送缓存已满返回SOCKET_ERROR_WOULDBLOCK，错误返回SOCKET_ERROR </dd></dl>

</div>
</div>
<a class="anchor" id="a2476dc993b75de2de00955468508fc8c"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::setLinger </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>on</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置linger模式 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">on</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>bool </dd></dl>

</div>
</div>
<a class="anchor" id="ac128e602223fe5a9416b3f1a67009282"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::setNonblocking </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>on</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置IO阻塞状态 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">on</td><td>true表示设置成阻塞 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>bool </dd></dl>

</div>
</div>
<a class="anchor" id="ad378344115303d72510ca9df7124629a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::setOption </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>level</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>optname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>optval</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">socklen_t&#160;</td>
          <td class="paramname"><em>optlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置套接字选项 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>本地套接字 </td></tr>
    <tr><td class="paramname">level</td><td>选项等级 </td></tr>
    <tr><td class="paramname">optname</td><td>选项名 </td></tr>
    <tr><td class="paramname">optval</td><td>选项值 </td></tr>
    <tr><td class="paramname">optlen</td><td>选项长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>bool </dd></dl>

</div>
</div>
<a class="anchor" id="a94e161e16e429d119a01aaf6c8a5f13a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Socket::setReuseAddr </td>
          <td>(</td>
          <td class="paramtype">sock_t&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>on</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置重用地址 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>本地套接字 </td></tr>
    <tr><td class="paramname">on</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>bool </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>E:/git/sock/sock/net/<a class="el" href="socket_8h_source.html">socket.h</a></li>
<li>E:/git/sock/src/net/<a class="el" href="socket_8cc.html">socket.cc</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.10
</small></address>
</body>
</html>
